def solve(str):
    str_list = str.split("/")
    stack = []
    for s in str_list:
        if s == "..":
            stack.pop()
        elif s and s != ".":
            stack.append(s)

    return "/" + "/".join(stack)


if __name__ == "__main__":
    str = "/home/user/Documents/../Pictures"
    print(solve(str))
